<?php

class Validator_Date extends Zend_Validate_Abstract
{
    const DATE = 'dateInvalide';
    
    private $pattern = "#^[0-9]{1,2}-[0-9]{1,2}-[0-9]{4}$#";
    
    protected $_messageTemplates = array(
    		self::DATE => '"%value%" n\'est pas une date valide');
    
    public function isValid ($value)
    {
    	$this->_setValue($value);
    
    	if(preg_match($this->pattern,$value, $matches))
    	{
    		if($value != $matches[0])
    		{
    			$this->_error(self::DATE);
    			return false;
    		}
    		else
    			return true;
    	}
    	else
    	{
    		$this->_error(self::DATE);
    		return false;
    	}
    }
}

?>